#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> sortEvenOdd(vector<int>& nums) {
        vector<int> num1;
        vector<int> num2;
        for (int i = 0; i < nums.size(); i += 2)
        {
            num1.push_back(nums[i]);
            if (i + 1 < nums.size())
                num2.push_back(nums[i + 1]);
        }
        sort(num1.begin(), num1.end());
        sort(num2.begin(), num2.end(), greater<int>());

        vector<int> ret;
        for (int i = 0; i < num1.size(); ++i)
        {
            ret.push_back(num1[i]);
            if (i < num2.size())
                ret.push_back(num2[i]);
        }

        return ret;
    }
};